//
//  TemplateFoundDetailsDXXLTableViewCell.m
//  YuTang
//
//  Created by 葛悦彣 on 2024/7/18.
//
#import "TemplateFoundDetailsDXXLTableViewCell.h"
#import "YTBaseSelectStringView.h"
#import "YTBaseSelectStringView.h"
#import "YTBaseEditorStringView.h"
#import "DigitalInputView.h"
#import "TemplateFoundDetailsDHTableViewCell.h"
@interface TemplateFoundDetailsDXXLTableViewCell ()<UITextFieldDelegate>

///必填
@property (nonatomic ,strong) UILabel * forceFlag;
@property (nonatomic ,strong) UILabel * name;
@property (nonatomic ,strong) UILabel * itemLab;


@end
@implementation TemplateFoundDetailsDXXLTableViewCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        [self setupView];
    }
    return self;
}


- (void)setupView{
    
    self.backgroundColor = UIColor.clearColor;
    self.contentView.backgroundColor = UIColor.whiteColor;
    self.userInteractionEnabled = YES;
    self.contentView.userInteractionEnabled = YES;
    
    UIView * makeview = [UIView new];
    makeview.backgroundColor = KcolorHex(@"#F6F7F9");
    [DTKTool YJ:kwt(5) andView:makeview];
    [self.contentView addSubview:makeview];
    [makeview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(0);
        make.bottom.right.offset(kwt(-10));
        make.left.offset(kwt(10));
    }];
    
    UILabel * forceFlag= [DTKTool labelWithText:@"*" andFont:kCFont(18) andTextColor:KcolorHex(@"#FA0F0F")];
    [makeview addSubview:forceFlag];
    self.forceFlag = forceFlag;
    forceFlag.mas_KLS().mas_KYS();
    [forceFlag mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(12));
        make.centerY.offset(0);
    }];
    
    
    UILabel * name = [DTKTool labelWithText:@"--" andFont:kCFont(18) andTextColor:KcolorHex(@"#222222")];
    [makeview addSubview:name];
    name.textAlignment = NSTextAlignmentLeft;
    name.mas_KLS().mas_KYS();
    self.name = name;
    [name mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(forceFlag.mas_right);
        make.centerY.offset(0);
    }];
    
    UIImageView * rightmodel = kimageView(@"template_enter");
    [makeview addSubview:rightmodel];
    [rightmodel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(kwt(-12));
        make.centerY.offset(0);
        make.width.height.offset(kwt(15));
    }];
    
    UILabel * itemLab = [DTKTool labelWithText:@"--" andFont:kFont(18) andTextColor:KcolorHex(@"#222222")];
    [makeview addSubview:itemLab];
    itemLab.textAlignment = NSTextAlignmentRight;
    self.itemLab = itemLab;
    [itemLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(name.mas_right).offset(kwt(20));
        make.centerY.offset(0);
        make.right.offset(kwt(-35));
    }];
    
    MJWeakSelf
    makeview.addClickBlock(^{
        [weakSelf openDX];
    });
}
- (void)openDX{
    if(self.openXLDXBlock){
        self.openXLDXBlock(self.model,self.model.itemSeledModel);
    }
}
- (void)setModel:(TemplateFoundDetailsTaskItemModelListModel *)model{
    _model = model;
    ///forceFlag 是否必填
    self.forceFlag.text = (model.forceFlag == 1)? @"*":@"";
    
    self.name.text = model.name;
    
    self.itemLab.text = model.itemSeledModel.name;
    
}

@end
@interface TemplateFoundDetailsDXXLZRWTableViewCell ()<UITextFieldDelegate>

///必填
@property (nonatomic ,strong) UILabel * forceFlag;
@property (nonatomic ,strong) UILabel * name;
@property (nonatomic ,strong) UILabel * itemLab;

///选择框
@property (nonatomic ,strong) UIView * XZView;

@end
@implementation TemplateFoundDetailsDXXLZRWTableViewCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        [self setupView];
    }
    return self;
}


- (void)setupView{
    
    self.backgroundColor = UIColor.clearColor;
    self.contentView.backgroundColor = UIColor.whiteColor;
    self.userInteractionEnabled = YES;
    self.contentView.userInteractionEnabled = YES;
    
    UIView * makeview = [UIView new];
    makeview.backgroundColor = KcolorHex(@"#F6F7F9");
    [DTKTool YJ:kwt(5) andView:makeview];
    [self.contentView addSubview:makeview];
    [makeview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(0);
        make.right.offset(kwt(-10));
        make.left.offset(kwt(10));
        make.height.offset(kwt(53));
    }];
    
    UILabel * forceFlag= [DTKTool labelWithText:@"*" andFont:kCFont(18) andTextColor:KcolorHex(@"#FA0F0F")];
    [makeview addSubview:forceFlag];
    self.forceFlag = forceFlag;
    forceFlag.mas_KLS().mas_KYS();
    [forceFlag mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(12));
        make.centerY.offset(0);
    }];
    
    
    UILabel * name = [DTKTool labelWithText:@"--" andFont:kCFont(18) andTextColor:KcolorHex(@"#222222")];
    [makeview addSubview:name];
    name.textAlignment = NSTextAlignmentLeft;
    name.mas_KLS().mas_KYS();
    self.name = name;
    [name mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(forceFlag.mas_right);
        make.centerY.offset(0);
    }];
    
    UIImageView * rightmodel = kimageView(@"template_enter");
    [makeview addSubview:rightmodel];
    [rightmodel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(kwt(-12));
        make.centerY.offset(0);
        make.width.height.offset(kwt(15));
    }];
    
    UILabel * itemLab = [DTKTool labelWithText:@"--" andFont:kFont(18) andTextColor:KcolorHex(@"#222222")];
    [makeview addSubview:itemLab];
    itemLab.textAlignment = NSTextAlignmentRight;
    self.itemLab = itemLab;
    [itemLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(name.mas_right).offset(kwt(20));
        make.centerY.offset(0);
        make.right.offset(kwt(-35));
    }];
    
    MJWeakSelf
    makeview.addClickBlock(^{
        [weakSelf openDX];
    });
    UIView * XZView = [UIView new];
    self.XZView = XZView;
    [self.contentView addSubview:XZView];
    [XZView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(12));
        make.right.offset(kwt(-12));
        make.top.offset(kwt(63));
        make.bottom.offset(kwt(-5));
    }];
    
}
- (void)openDX{
    if(self.openXLDXBlock){
        self.openXLDXBlock(self.model,self.model.itemSeledModel);
    }
}
- (void)setModel:(TemplateFoundDetailsTaskItemModelListModel *)model{
    _model = model;
    ///forceFlag 是否必填
    self.forceFlag.text = (model.forceFlag == 1)? @"*":@"";
    
    self.name.text = model.name;
    
    self.itemLab.text = model.itemSeledModel.name;
 
    [self.XZView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
    CGFloat X = kwt(10);
    CGFloat Y = 0;
    MJWeakSelf
    for (TemplateFoundDetailsItemModelListModel * itemList in model.itemModelList) {//子选项
        if(itemList.checkedFlag == 1){
            if(itemList.itemList.count > 1){///多个任务包一起
                UIView * listview = [UIView new];
                listview.backgroundColor = KcolorHex(@"#F6F7F9");
                [self.XZView addSubview:listview];
                [DTKTool YJ:kwt(5) andView:listview];
                [listview mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.left.right.offset(0);
                    make.top.offset(Y) ;
                    make.height.offset(itemList.itemListViewH - kwt(10));
                }];
                UILabel * lab = [DTKTool labelWithText:itemList.name andFont:kFont(17) andTextColor:KcolorHex(@"#222222")];
                [listview addSubview:lab];
                lab.textAlignment = NSTextAlignmentCenter;
                [lab mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.left.offset(kwt(12));
                    make.top.offset(kwt(16));
                }];
               CGFloat tempY = kwt(45);
                for (TemplateFoundDetailsItemListModel * item in itemList.itemList) {
                    /// 样式;1:多项选择 2:下单单选3:数字输入框4:单行文本 5:多行文本
                    if(item.pattern == 1){
                        CGFloat X = kwt(10);
                        CGFloat dxY = kwt(45);
                        UIView * dxview = [UIView new];
                        dxview.backgroundColor = KcolorHex(@"#F6F7F9");
                        [DTKTool YJ:kwt(5) andView:dxview];
                        [listview addSubview:dxview];
                        [dxview mas_makeConstraints:^(MASConstraintMaker *make) {
                            make.top.offset(tempY);
                            make.left.right.offset(0);
                            make.height.offset(item.viewH - kwt(10));
                        }];
                        
                        
                        UILabel * lab = [DTKTool labelWithText:@"" andFont:kCFont(17) andTextColor:KcolorHex(@"#222222")];
                        lab.attributedText = [DTKTool AttributedStringWithStr:[NSString stringWithFormat: @"%@%@",((item.forceFlag == 1)?@"*":@""),item.name] andNodeColor:KcolorHex(@"#222222") andSeledColor:KcolorHex(@"#FA0F0F") andFont:kCFont(17) andPattenr:@"[*]"];
                        [dxview addSubview:lab];
                        [lab mas_makeConstraints:^(MASConstraintMaker *make) {
                            make.left.offset(kwt(10));
                            make.top.offset(kwt(14));
                            make.height.offset(kwt(18));
                        }];
                        UILabel * templab = [DTKTool labelWithText:@" (可多选)" andFont:kFont(17) andTextColor:KcolorHex(@"#7F7F7F")];
                        [dxview addSubview:templab];
                        templab.textAlignment = NSTextAlignmentCenter;
                        [templab mas_makeConstraints:^(MASConstraintMaker *make) {
                            make.left.equalTo(lab.mas_right);
                            make.centerY.equalTo(lab);
                        }];
                    
                        
                        for (TemplateFoundDetailsChildrenModelListModel * childModel in item.childrenModelList) {
                            
                            UIView * btnview = [UIView new];
                            btnview.addClickBlock(^{
                                [weakSelf btnclick:childModel];
                            });
                            [DTKTool YJBK:kwt(6) andView:btnview andWidth:1 andColor:childModel.checkedFlag?KcolorHex(@"#0967FF"):KcolorHex(@"#BFBFBF")];
                            UILabel * lab = [DTKTool labelWithText:childModel.name andFont:kFont(16) andTextColor:childModel.checkedFlag?KcolorHex(@"#0967FF"):KcolorHex(@"#373C45")];
                            [btnview addSubview:lab];
                            lab.textAlignment = NSTextAlignmentCenter;
                            [lab mas_makeConstraints:^(MASConstraintMaker *make) {
                                make.left.offset(kwt(10));
                                make.right.offset(kwt(-10));
                                make.centerY.offset(0);
                            }];
                            if(childModel.checkedFlag){
                                UIImageView * xzimg = kimageView(@"template_selete");
                                [btnview addSubview:xzimg];
                                [xzimg mas_makeConstraints:^(MASConstraintMaker *make) {
                                    make.right.bottom.offset(0);
                                    make.height.offset(kwt(11));
                                    make.width.offset(kwt(10));
                                }];
                            }
                            
                            [dxview addSubview:btnview];
                            if(X + childModel.nameW > kwt(340)){
                                X = kwt(10);
                                dxY += kwt(48);
                            }
                            btnview.frame = CGRectMake(X, dxY, childModel.nameW, kwt(32));
                            X += childModel.nameW + kwt(10);
                        }
                        tempY += item.viewH - kwt(10);
                    } else  if(item.pattern == 2){
                        YTBaseSelectStringView * view = [YTBaseSelectStringView NewViewWithNil];
                        view.forceFlag = item.forceFlag;
                        view.name = item.name;
                        view.content = item.seledModel.name;
                        view.block = ^(NSString * _Nonnull content) {
                            NSMutableArray * nameArray = [NSMutableArray array];
                            int i = 0;
                            int selectIndex = 0;
                            for (TemplateFoundDetailsChildrenModelListModel * itemmodel in item.childrenModelList) {
                                [nameArray addObject:itemmodel.name];
                                if([item.seledModel.name isEqualToString: itemmodel.name]){
                                    selectIndex = i;
                                }
                                i ++;
                            }
                            [BRStringPickerView showPickerWithTitle:[NSString stringWithFormat:@"请选择%@",item.name] dataSourceArr:nameArray selectIndex:selectIndex resultBlock:^(BRResultModel * _Nullable resultModel) {
                                for (TemplateFoundDetailsChildrenModelListModel * itemmodel in item.childrenModelList) {
                                    if([itemmodel.name isEqualToString:resultModel.value]){
                                        itemmodel.checkedFlag = 1;
                                    } else {
                                        itemmodel.checkedFlag = 0;
                                    }
                                }
                                if(weakSelf.openReloadBlock){
                                    weakSelf.openReloadBlock();
                                }
                            }];
                        };
                        [listview addSubview: view];
                        [view mas_makeConstraints:^(MASConstraintMaker *make) {
                            make.left.right.offset(0);
                            make.top.offset(tempY);
                            make.height.offset(item.viewH - kwt(10));
                        }];
                        tempY += item.viewH - kwt(10);
                    } else  if(item.pattern == 3){
                        
                        UIView * makeview = [UIView new];
                        makeview.backgroundColor = KcolorHex(@"#F6F7F9");
                        [DTKTool YJ:kwt(5) andView:makeview];
                        [listview addSubview:makeview];
                        [makeview mas_makeConstraints:^(MASConstraintMaker *make) {
                            make.top.offset(tempY);
                            make.left.right.offset(0);
                            make.height.offset(item.viewH - kwt(10));
                        }];
                        
                        UILabel * name = [DTKTool labelWithText:@"" andFont:kCFont(18) andTextColor:KcolorHex(@"#222222")];
                        [makeview addSubview:name];
                        name.attributedText = [DTKTool AttributedStringWithStr:[NSString stringWithFormat:@"%@%@",(item.forceFlag==1)?@"*":@"",item.name] andNodeColor:KcolorHex(@"#222222") andSeledColor:KcolorHex(@"#FA0F0F") andFont:kCFont(18) andPattenr:@"[*]"];
                        self.name = name;
                        [name mas_makeConstraints:^(MASConstraintMaker *make) {
                            make.left.offset(kwt(12));
                            make.centerY.offset(0);
                            make.width.offset(kwt(145));
                        }];
                        
                        DigitalInputView * inputview = [DigitalInputView DKNewView];
                        inputview.model = item;///有数据不管类型
                        [makeview addSubview:inputview];
                        inputview.openReloadBlock = ^{
                            if(weakSelf.openReloadBlock){
                                weakSelf.openReloadBlock();
                            }
                        };
                        inputview.openHUDBlock = ^(NSString * _Nonnull str) {
                            if(weakSelf.openHUDBlock){
                                weakSelf.openHUDBlock(str);
                            }
                        };
                        [inputview mas_makeConstraints:^(MASConstraintMaker *make) {
                            make.right.offset(kwt(-12));
                            make.centerY.offset(0);
                            make.width.offset(kwt(170));
                            make.height.offset(kwt(32));
                        }];
                        
                        
                        tempY += item.viewH - kwt(10);
                        
                    } else  if(item.pattern == 4){
                        
                        YTBaseEditorStringView * view = [YTBaseEditorStringView NewViewWithNil];
                        view.forceFlag = item.forceFlag;
                        view.name = item.name;
                        view.content = item.content;
                        view.block = ^(NSString * _Nonnull content) {
                            item.content = content;
                        };
                        
                        [listview addSubview: view];
                        [view mas_makeConstraints:^(MASConstraintMaker *make) {
                            make.left.right.offset(0);
                            make.top.offset(tempY);
                            make.height.offset(item.viewH - kwt(10));
                        }];
                        tempY+= item.viewH - kwt(10);
                    } else  if(item.pattern == 5){
                        TemplateFoundDetailsDHView * view = [TemplateFoundDetailsDHView NewView];
                        view.model = item;
                        [listview addSubview: view];
                        [view mas_makeConstraints:^(MASConstraintMaker *make) {
                            make.left.right.offset(0);
                            make.top.offset(tempY);
                            make.height.offset(item.viewH - kwt(10));
                        }];
                        tempY += item.viewH - kwt(10);
                    }
                }
                Y += itemList.itemListViewH;
            } else {///单个任务项
                for (TemplateFoundDetailsItemListModel * item in itemList.itemList) {
                    /// 样式;1:多项选择 2:下单单选3:数字输入框4:单行文本 5:多行文本
                    if(item.pattern == 1){
                        CGFloat X = kwt(10);
                        CGFloat dxY = kwt(45);
                        UIView * dxview = [UIView new];
                        dxview.backgroundColor = KcolorHex(@"#F6F7F9");
                        [DTKTool YJ:kwt(5) andView:dxview];
                        [self.XZView addSubview:dxview];
                        [dxview mas_makeConstraints:^(MASConstraintMaker *make) {
                            make.top.offset(Y);
                            make.left.right.offset(0);
                            make.height.offset(item.viewH - kwt(10));
                        }];
                        
                        
                        UILabel * lab = [DTKTool labelWithText:@"" andFont:kCFont(17) andTextColor:KcolorHex(@"#222222")];
                        lab.attributedText = [DTKTool AttributedStringWithStr:[NSString stringWithFormat: @"%@%@",((item.forceFlag == 1)?@"*":@""),item.name] andNodeColor:KcolorHex(@"#222222") andSeledColor:KcolorHex(@"#FA0F0F") andFont:kCFont(17) andPattenr:@"[*]"];
                        [dxview addSubview:lab];
                        [lab mas_makeConstraints:^(MASConstraintMaker *make) {
                            make.left.offset(kwt(10));
                            make.top.offset(kwt(14));
                            make.height.offset(kwt(18));
                        }];
                        UILabel * templab = [DTKTool labelWithText:@" (可多选)" andFont:kFont(17) andTextColor:KcolorHex(@"#7F7F7F")];
                        [dxview addSubview:templab];
                        templab.textAlignment = NSTextAlignmentCenter;
                        [templab mas_makeConstraints:^(MASConstraintMaker *make) {
                            make.left.equalTo(lab.mas_right);
                            make.centerY.equalTo(lab);
                        }];
                     
                        for (TemplateFoundDetailsChildrenModelListModel * childModel in item.childrenModelList) {
                            
                            UIView * btnview = [UIView new];
                            btnview.addClickBlock(^{
                                [weakSelf btnclick:childModel];
                            });
                            [DTKTool YJBK:kwt(6) andView:btnview andWidth:1 andColor:childModel.checkedFlag?KcolorHex(@"#0967FF"):KcolorHex(@"#BFBFBF")];
                            UILabel * lab = [DTKTool labelWithText:childModel.name andFont:kFont(16) andTextColor:childModel.checkedFlag?KcolorHex(@"#0967FF"):KcolorHex(@"#373C45")];
                            [btnview addSubview:lab];
                            lab.textAlignment = NSTextAlignmentCenter;
                            [lab mas_makeConstraints:^(MASConstraintMaker *make) {
                                make.left.offset(kwt(10));
                                make.right.offset(kwt(-10));
                                make.centerY.offset(0);
                            }];
                            if(childModel.checkedFlag){
                                UIImageView * xzimg = kimageView(@"template_selete");
                                [btnview addSubview:xzimg];
                                [xzimg mas_makeConstraints:^(MASConstraintMaker *make) {
                                    make.right.bottom.offset(0);
                                    make.height.offset(kwt(11));
                                    make.width.offset(kwt(10));
                                }];
                            }
                            
                            [dxview addSubview:btnview];
                            if(X + childModel.nameW > kwt(340)){
                                X = kwt(10);
                                dxY += kwt(48);
                            }
                            btnview.frame = CGRectMake(X, dxY, childModel.nameW, kwt(32));
                            X += childModel.nameW + kwt(10);
                        }
                        Y+= item.viewH;
                    } else  if(item.pattern == 2){
                        YTBaseSelectStringView * view = [YTBaseSelectStringView NewViewWithUP];
                        view.forceFlag = item.forceFlag;
                        view.name = item.name;
                        view.content = item.seledModel.name;
                        view.block = ^(NSString * _Nonnull content) {
                            NSMutableArray * nameArray = [NSMutableArray array];
                            int i = 0;
                            int selectIndex = 0;
                            for (TemplateFoundDetailsChildrenModelListModel * itemmodel in item.childrenModelList) {
                                [nameArray addObject:itemmodel.name];
                                if([item.seledModel.name isEqualToString: itemmodel.name]){
                                    selectIndex = i;
                                }
                                i ++;
                            }
                            [BRStringPickerView showPickerWithTitle:[NSString stringWithFormat:@"请选择%@",item.name] dataSourceArr:nameArray selectIndex:selectIndex resultBlock:^(BRResultModel * _Nullable resultModel) {
                                for (TemplateFoundDetailsChildrenModelListModel * itemmodel in item.childrenModelList) {
                                    if([itemmodel.name isEqualToString:resultModel.value]){
                                        itemmodel.checkedFlag = 1;
                                    } else {
                                        itemmodel.checkedFlag = 0;
                                    }
                                }
                                if(weakSelf.openReloadBlock){
                                    weakSelf.openReloadBlock();
                                }
                            }];
                        };
                        [self.XZView addSubview: view];
                        [view mas_makeConstraints:^(MASConstraintMaker *make) {
                            make.left.right.offset(0);
                            make.top.offset(Y);
                            make.height.offset(item.viewH);
                        }];
                        Y+= item.viewH;
                    } else  if(item.pattern == 3){
                        
                        UIView * makeview = [UIView new];
                        makeview.backgroundColor = KcolorHex(@"#F6F7F9");
                        [DTKTool YJ:kwt(5) andView:makeview];
                        [self.XZView addSubview:makeview];
                        [makeview mas_makeConstraints:^(MASConstraintMaker *make) {
                            make.top.offset(Y);
                            make.left.right.offset(0);
                            make.height.offset(item.viewH - kwt(10));
                        }];
                        
                        UILabel * name = [DTKTool labelWithText:@"" andFont:kCFont(18) andTextColor:KcolorHex(@"#222222")];
                        [makeview addSubview:name];
                        name.attributedText = [DTKTool AttributedStringWithStr:[NSString stringWithFormat:@"%@%@",(item.forceFlag==1)?@"*":@"",item.name] andNodeColor:KcolorHex(@"#222222") andSeledColor:KcolorHex(@"#FA0F0F") andFont:kCFont(18) andPattenr:@"[*]"];
                        self.name = name;
                        [name mas_makeConstraints:^(MASConstraintMaker *make) {
                            make.left.offset(kwt(12));
                            make.centerY.offset(0);
                            make.width.offset(kwt(145));
                        }];
                        
                        DigitalInputView * inputview = [DigitalInputView DKNewView];
                        inputview.model = item;///有数据不管类型
                        [makeview addSubview:inputview];
                        inputview.openReloadBlock = ^{
                            if(weakSelf.openReloadBlock){
                                weakSelf.openReloadBlock();
                            }
                        };
                        inputview.openHUDBlock = ^(NSString * _Nonnull str) {
                            if(weakSelf.openHUDBlock){
                                weakSelf.openHUDBlock(str);
                            }
                        };
                        [inputview mas_makeConstraints:^(MASConstraintMaker *make) {
                            make.right.offset(kwt(-12));
                            make.centerY.offset(0);
                            make.width.offset(kwt(170));
                            make.height.offset(kwt(32));
                        }];
                        
                        
                        Y+= item.viewH;
                        
                    } else  if(item.pattern == 4){
                        
                        YTBaseEditorStringView * view = [YTBaseEditorStringView NewViewWithUP];
                        view.forceFlag = item.forceFlag;
                        view.name = item.name;
                        view.content = item.content;
                        view.block = ^(NSString * _Nonnull content) {
                            item.content = content;
                        };
                        
                        [self.XZView addSubview: view];
                        [view mas_makeConstraints:^(MASConstraintMaker *make) {
                            make.left.right.offset(0);
                            make.top.offset(Y);
                            make.height.offset(item.viewH);
                        }];
                        Y+= item.viewH;
                    } else  if(item.pattern == 5){
                        TemplateFoundDetailsDHView * view = [TemplateFoundDetailsDHView NewView];
                        view.model = item;
                        [self.XZView addSubview: view];
                        [view mas_makeConstraints:^(MASConstraintMaker *make) {
                            make.left.right.offset(0);
                            make.top.offset(Y);
                            make.height.offset(item.viewH);
                        }];
                        Y+= item.viewH;
                    }
                }
            }
        }
    }
}

- (void)btnclick:(TemplateFoundDetailsItemModelListModel *)model{

    model.checkedFlag = (model.checkedFlag == 1)?0:1;
    
    if(self.openReloadBlock){
        self.openReloadBlock();
    }
}

@end
